package org.gpf.singleton;

public class Singleton5 {

	/**
	 * 加入volatile关键字，防止JVM代码优化造成线程不安全
	 */
	private volatile static Singleton5 singleton = null;

	private Singleton5() {

	}

	public static Singleton5 getInstance() {

		if (singleton == null) {
			synchronized (Singleton5.class) {
				if (singleton == null) {
					singleton = new Singleton5();
				}
			}
		}
		return singleton;
	}
}
